package com.dabai.iot.core.dubbo;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dabai.iot.core.api.RemoteProductService;
import com.dabai.iot.core.entity.ProductEntity;
import com.dabai.iot.core.entity.ProductTopicEntity;
import com.dabai.iot.core.service.IProductService;
import com.dabai.iot.core.service.IProductTopicService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 产品服务实现类
 *
 * @author kev1n
 */
@Service
@AllArgsConstructor
public class RemoteProductServiceImpl implements RemoteProductService {

    private IProductService productService;
    private IProductTopicService productTopicService;

    @Override
    public Long productCount(String tenantId) {
        return productService.count(Wrappers.<ProductEntity>query().lambda().eq(ProductEntity::getTenantId, tenantId));
    }

    @Override
    public List<ProductTopicEntity> getTopicList(Long productId, String topicSourceType, String topicDirection) {
        return productTopicService.selectList(productId, topicSourceType, topicDirection);
    }
}
